﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Smtp_server
{
    public partial class Main : Form
    {
        private Logger logger;
        private DBagent dbagent;
        private Daemon daemon;
        
        public Main()
        {
            this.InitializeComponent();
            this.dbagent = new DBagent();
            this.logger = new Logger();
            this.daemon = new Daemon(logger,dbagent);
            lookDisable();
        }

        private void mnAbout_Click(object sender, EventArgs e)
        {
            Form frmAbout = new About();
            frmAbout.ShowDialog();
        }

        private void mnLogs_Click(object sender, EventArgs e)
        {
            Form frmLogs = new LoggerView(logger);
            frmLogs.ShowDialog();
        }

        private void mnEmail_Click(object sender, EventArgs e)
        {
            Form frmEmailListView = new EmailListView(dbagent);
            frmEmailListView.ShowDialog();
        }

        private void mnSettings_Click(object sender, EventArgs e)
        {
            Form frmSettings = new Settings(logger,dbagent);
            frmSettings.ShowDialog();
        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            this.daemon.Start();
            lookEnable();
        }
        private void btnStop_Click(object sender, EventArgs e)
        {
            this.daemon.Stop();
            lookDisable();
        }

        private void lookEnable() 
        {
            this.pctStatusEnable.Visible = true;
            this.pctStatusDisable.Visible = false;
            this.lblStatus.Text = "Server up";
        }
        private void lookDisable() 
        {
            this.pctStatusEnable.Visible = false;
            this.pctStatusDisable.Visible = true; 
            this.lblStatus.Text = "Server down";
        }

        private void Main_Load(object sender, EventArgs e)
        {

        }

        


    }
}